<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>欢迎使用</title>
		
		<link type="text/css" rel="stylesheet" href="./css/cm-default.css">
		<link type="text/css" rel="stylesheet" href="./ligerUI/skins/Aqua/css/ligerui-all.css" />
		<script type="text/javascript" src="./js/jquery-min.js"></script>
		<script type="text/javascript" src="./ligerUI/js/ligerui.min.js"></script>
		<script type="text/javascript" src="./js/md5.js"></script>
		<script type="text/javascript" src="./js/common.js"></script>
		
		<style type="text/css">
			.btn-margin{margin:0 15px 0 70px;}
		    .l-topmenu{ margin:0; padding:0; height:31px; line-height:31px; background:url('./images/top.jpg') repeat-x bottom;  position:relative; border-top:1px solid #1D438B;  }
		    .l-topmenu-logo{ color:#E7E7E7; padding-left:35px; line-height:26px;}
			#msgDiv{height: 20px; color: #FD5A3E;}
			div.login{width: 280px; margin: 15% 0 0 40%; border: 3px solid #DDDDDD; padding: 8px; background-color: #EEEEEE;}
			div.fields{height:93px;padding-top:5px;}
			.fields label{margin: 0 20px 0 15px;}
			.diff{margin:3px 0;}
		</style>
		<script>
			$(function() {
				$("body").bind("keydown", execLogin);
				$("#userName").focus();
				$("#pageloading").hide();
			});

			var sts = true;
			function toLogin() {
				if (!sts)
					return;
				
				var uname = $("#userName");
				if (uname.val() === "") {
					uname.ligerTip({ content:"用户名不能为空", width: 100});
					uname.focus();
					return;
				}
				uname.ligerHideTip();
				var pwd = $("#passwd");
				if (pwd.val() === "") {
					pwd.ligerTip({ content:"密码不能为空", width: 100});
					pwd.focus();
					return;
				}
				pwd.ligerHideTip();

				var url = "rbac/cmUser.do?method=login";
				var data = "uname=" + uname.val() + "&pwd=" + hex_md5(pwd.val()).toUpperCase();
				sts = false;
				ajaxSubmit(url, data, onSuccess, function (data) {
					alert("登录失败！\n[原因]系统异常");
					sts = true;
				});
			}
			function onSuccess(data) {
				var uname = $("#userName");
				var pwd = $("#passwd");
				if (data["valid"] === "1") {
					window.location = "main.html"
				} else if (data["valid"] === "2") {
					$.ligerDialog.error("您使用的用户已失效，请联系系统管理员");
					uname.focus();
					pwd.val("");
					return;
				} else {
					$.ligerDialog.error("您输入的用户名或密码有误。", "错误", function() {
						pwd.val("");
						uname.focus();
						return;
					});
				}
				sts = true;
			}
			function execLogin(oEvent) {
				if(sts && oEvent.keyCode == 13) {
					toLogin();
				}
			}
		</script>
	</head>
	<body>
		<div id="pageloading"></div>  
		<div id="topmenu" class="l-topmenu">
		    <div class="l-topmenu-logo" style="font-weight: bold; font-size: 16px;">XXX系统</div>
		</div>
		<div id="formDiv" class="login">
			<div class="fields">
				<label>用户名</label><input type="text" id="userName" class="s-text diff txt-def" style="margin-right: 15px;" />
				<label>密　码</label><input type="password" class="s-text diff txt-def" id="passwd" />
				<input type="button" value="登录" onclick="toLogin();" style="margin: 10px 8px 0 27%;" />
				<input type="button" value="清空" onclick="toReset();" />
			</div>
		</div>
	</body>
</html>